import Taro, { Component } from '@tarojs/taro'
import { View, Text,Image } from '@tarojs/components'
import { AtSteps, AtIcon ,AtTimeline} from 'taro-ui'
import './medicalStatus.css'
import sanjiao from '../../../img/sanjiao.png'
import medica2 from '../../../img/medica2.png'
import app from '../../../main.js'

export default class MedicalStatus extends Component{

    config={
        navigationBarTitleText: '病历状态'

    }
    constructor(){
        super(...arguments)
        this.state = {
            current: 0,
            current2: 0,
            //病历数据
            patientName:'a',
            projectName:'a',
            code:'1',
            case_course_amount:0,
            //病程状态
            items : [
                {title:'待提交'},
                {title:'待初审'},
                {title:'初审待修改'},
                {title:'待终审'},
                {title:'终审待修改'},
                {title:'待付款'},
                {title:'已付款'},
            ],
            status: '',//当前状态
            titleItem: {display:'left:5%;'},
            //操作详情
            items2 : [
                {title:'已支付了劳务款项', desc:''},
                {title:'通过了初审', desc:''},
                {title:'通过了终审', desc:''},
                {title:'提交了首诊病程', desc:''},
                {title:'提交了复诊病程', desc:''},
                {title:'创建病历', desc:''},
            ],
            arr:{},//当前操作状态
        }
    }
    // get 获取患者的详细信息    
    getCase() {         
        let me = this;
        let data={
            id: this.$router.params.id
        }
        app.get('web/case/get',data,function(res){
            me.setState({
                patientName:res.data.result.patient_name,
                projectName:res.data.result.project_name,
                code:res.data.result.code,
                status:res.data.result.status,
                case_course_amount: res.data.result.case_course_amount,
            },()=>{
                console.log('11');
                switch(me.state.status){
                    case '待提交':
                    me.setState({
                        current:0
                    });
                    break;
                    case '待初审':
                    me.setState({
                        current:1
                    });
                    break;
                    case '初审待修改':
                    me.setState({
                        current:2
                    });
                    break;
                    case '待终审':
                    me.setState({
                        current:3
                    });
                    break;
                    case '终审待修改':
                    me.setState({
                        current:4
                    });
                    break;
                    case '待付款':
                    me.setState({
                        current:5
                    });
                    break;
                    case '已付款':
                    me.setState({
                        current:6
                    });
                    break;
                    default:
                    break;
                }
            })
        })
    }

    // get 病历操作详情
    getCaseOperation(){
        let me = this;
        let items =[];
        //当前操作
        let caozuo;
        let data={
            case_detail_id: this.$router.params.id,
        }
        app.get('web/case_operation/all', data, function(res){
            for(let val of res.data.result){
                items.push({title: val.title,desc: val.created_at})
            }
            me.setState({
                items2:items,
            })
        })
    }

    
    componentWillMount () {
        this.getCase();
        this.getCaseOperation();
    }
    
    componentDidShow() {    
    }
    componentDidMount () {}

    componentWillUnmount () {}

    componentDidHide () {}


    render(){

        return(
            <View>
                <View className='top'>
                    <View>
                        <Image className='bingli-image' src={medica2} />
                        <View className='binglishu'>{this.state.case_course_amount}</View>
                    </View>
                    <View className='bingliinfo'>
                        <View className='bingliinfolist'>
                            <Text className='bingliinfolistTitle'>患者：</Text>
                            <Text>{this.state.patientName}</Text>
                        </View>
                        <View className='bingliinfolist'>
                            <Text className='bingliinfolistTitle'>项目：</Text>
                            <Text>{this.state.projectName}</Text>
                        </View>
                        <View className='bingliinfolist'>
                            <Text className='bingliinfolistTitle'>病历编号</Text>
                            <Text>{this.state.code}</Text>
                        </View>
                    </View>
                </View>
                <View className='verStep'>
                    <AtSteps
                        items={this.state.items}
                        current={this.state.current}
                    />
                </View>
                <View className='message'>
                    <AtIcon customStyle='margin:0px 5px 5px 0px;' value='message' size='14'/> <Text>联系医助</Text>
                </View>
                <View className='contentTitle'>
                    <Text>操作详情</Text>
                </View>
                <View className='horStep'>
                    <AtSteps
                        items={this.state.items2}
                        current={this.state.current2}
                    />
                </View>
            </View>
        )
    }
}